import { Injectable } from '@angular/core';
import { User } from '../model/User';

@Injectable()
export class AuthService {

  KEY = 'authorization';

  constructor() { }

  set token(token) {
    localStorage.setItem(this.KEY, JSON.stringify(token));
  }

  get token() {
    return JSON.parse(localStorage.getItem(this.KEY) || '{}') || {};
  }

  logout() {
    localStorage.removeItem(this.KEY);
  }
}
